import whois
import random
import sys
from colorama import init, Fore, Style

# Initialize colorama
init()

# Define different color lists
colors = [Fore.RED, Fore.GREEN, Fore.YELLOW, Fore.BLUE, Fore.MAGENTA, Fore.CYAN, Fore.WHITE]

# Randomly assign colors
def get_random_color():
    return random.choice(colors)

def whois_query(domain):
    try:
        w = whois.whois(domain)
        return w
    except Exception as e:
        return str(e)

def print_colored_info(whois_info):
    if isinstance(whois_info, str):
        print(f"{get_random_color()}{whois_info}{Style.RESET_ALL}")
    else:
        for key, value in whois_info.items():
            print(f"{get_random_color()}{key}: {value}{Style.RESET_ALL}")

if __name__ == "__main__":
    if len(sys.argv) != 2:
        print(f"{Fore.RED}Usage: python3 python_whois.py <domain>{Style.RESET_ALL}")
        sys.exit(1)

    domain = sys.argv[1]
    whois_info = whois_query(domain)
    print_colored_info(whois_info)

# pip install python-whois colorama
# sansjtw